# -*- coding: utf-8 -*-
import urllib
from urllib import parse, request
from tuntun.settings import APP_CODE
import json


def IdCard(real_name, card_no):
    host = 'http://idcard.market.alicloudapi.com'
    path = '/lianzhuo/idcard'
    method = 'GET'
    app_code = APP_CODE
    querys = 'cardno=' + card_no + '&name=' + real_name
    qu = urllib.parse.urlencode({'cardno': card_no, 'name': real_name})
    url = host + path + '?' + qu

    header_dict = {'Authorization': 'APPCODE ' + app_code}
    request = urllib.request.Request(url=url, headers=header_dict)
    response = urllib.request.urlopen(request)
    content = response.read()
    re = json.loads(content.decode(encoding='utf-8'))
    print(re)
    return re


if __name__ == '__main__':
    re = IdCard("1", "1")
    print(re)
